//加载有导入功能的窗口
OB.RemoteCallManager.call("com.basis.handler.LoadImportButtonHandler", {}, {async: false}, 
	function(response, data, request) {
		if (data.success) {
			var list = data.list;
			for (var i = 0;i < list.length;i ++) {
				Creatae_Emes_DataImport_Button(list[i].code, list[i].name, list[i].tabId, list[i].templatePath, list[i].hideImpBtn);
			}
		} else {
			isc.showMessage(data.msg, top.isc.OBMessageBar.TYPE_ERROR);
		}
        creataeFileUploadButton();
	}
);

function Creatae_Emes_DataImport_Button(code, name, tabId, templatePath, hideImpBtn) {
	var Import_Button = {
		id: "Import_Button_" + code,
		title: "导入",
		buttonType: 'import',
		action: function() {
			var _self = this;
			OB.MyActiveViewRefresh = function() {
				_self.view.refresh();
			};
			OB.Layout.ClassicOBCompatibility.Popup.open(
				"import_Data_" + code,
				500,
				150,
				OB.Application.contextUrl + "web/com.basic/html/importData.html?code=" + code,
				name, window, false, false, null, true, true);
		}
	};
	var Down_Template = {
		id : "Down_Template_" + code,
		title : "模板",
		buttonType: 'saveclose',
		action : function() {
			if (templatePath) {
                window.open(OB.Application.contextUrl + templatePath);
			} else {
                window.open(OB.Application.contextUrl + "downImportTemplate.html?code=" + code);
			}
		}
	};
	
	OB.ToolbarRegistry.registerButton(Down_Template.id, isc.OBToolbarIconButton, Down_Template, 100, tabId);
	//如果设置的是隐藏导入按钮
	if (hideImpBtn == "Y") {
		return;
	}
	OB.ToolbarRegistry.registerButton(Import_Button.id, isc.OBToolbarIconButton, Import_Button, 100, tabId);
}
function creataeFileUploadButton() {
    var Import_Button = {
        id: "_file_upload_Button_001",
        title: "上传",
        buttonType: 'import',
        action: function() {
            var _self = this;
            OB.MyActiveViewRefresh = function() {
                _self.view.refresh();
            };
            OB.Layout.ClassicOBCompatibility.Popup.open(
                "_file_upload_Btn_001",
                450, 240,
                OB.Application.contextUrl + "web/com.basic/html/uploadFile.html",
                name, window, false, false, null, true, true);
        }
    };

    OB.ToolbarRegistry.registerButton(Import_Button.id, isc.OBToolbarIconButton, Import_Button,
		100, 'CCB48FBBECCB4F58B567EF8890116B89');
}